package com.exam.gateway.config;

import com.exam.auth.utils.RsaUtils;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import javax.annotation.PostConstruct;
import java.io.File;
import java.security.PrivateKey;
import java.security.PublicKey;

/**
 * @ClassName : JwtProperties
 * @Description : 读取配置
 * @Author : WHB
 */

@Data
@ConfigurationProperties(prefix = "exam.jwt")
public class JwtProperties {

    private String pubKeyPath;// 公钥
    private String cookieName; //token名称

    private PublicKey publicKey; // 公钥

    // 对象实例化后，就读取公钥和私钥   PostConstruct注解在对象实例化之后执行
    @PostConstruct
    public void init() throws Exception {
        // 读取公钥和私钥
         this.publicKey = RsaUtils.getPublicKey(pubKeyPath);
    }
}
